<template>
  <div>
    <template>
      <!--页头组件-->
      <el-page-header style="background-color: #0095d7;color: white;line-height: 60px"
                      @back="goBack" content="查看物资信息页面"></el-page-header>
      <!--分割线-->
      <el-divider></el-divider>
      <!--name代表上传文件时 文件的参数名
          limit="1" 设置只能选择一张图片
      -->
      <el-card>
        <el-form>

          <el-form-item label="物资名称" label-width="80px">
            <el-input v-model="item.name" readonly></el-input>
          </el-form-item>
          <el-form-item label="描述" label-width="80px">
            <el-input v-model="item.description" readonly></el-input>
          </el-form-item>
          <el-form-item label="库存" label-width="80px">
            <el-input v-model="item.inventory" readonly></el-input>
          </el-form-item>
          <el-form-item label="申请条件 " label-width="80px">
            <el-input v-model="item.requireApplication" readonly></el-input>
          </el-form-item>
          <el-form-item label="状态" label-width="80px">
            <el-input v-model="isEnable" readonly ></el-input>
          </el-form-item>
          <el-form-item label="提交时间" label-width="80px">
            <el-input v-model="item.itemCreate" readonly ></el-input>
          </el-form-item>
          <el-form-item label="最后修改时间" label-width="80px">
            <el-input v-model="item.itemModified" readonly ></el-input>
          </el-form-item>
        </el-form>
      </el-card>
    </template>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        name: this.$route.query.name,
        isEnable:'',
        item:{
          description:"",
          inventory:"",
          requireApplication:"",
          itemCreate:"",
          itemModified:""
        },
        isEnableArr:[{name:'启用',isEnable:1},{name:'禁用',isEnable:0}],
      }
    },
    created() {
      this.getData();
    },

    methods: {
      getData(){
        console.log("name========"+this.name)
        // 发请求获取用户信息
        // http://176.17.10.223:18080/user/details?username=username031
        let url = 'http://176.17.10.223:18081/item/details'
        let data = 'name=' + this.name;
        this.axios.post(url,data).then( (response)=> {
          // 将得到的用户数据存储起来
          this.item = response.data.data;
          // 判断查到的用户数据中的isEnable是否为1
          if (response.data.data.isEnable === 1){
            this.isEnable='启用';
          }else {
            this.isEnable='禁用';
          }
        })

      },
      goBack(){
        //返回上一页面
        history.back();
      }
    },
  }
</script>
<style>
  .el-input__inner {
    width: 500px;
  }
  .el-card{
    width: 100%;
    height: 100%;
  }
</style>